//
// Copyright (C) Microsoft. All rights reserved.  
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not 
// use this file except in compliance with the License.  You may obtain a copy 
// of the License at http://www.apache.org/licenses/LICENSE-2.0  
// 
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
// MERCHANTABLITY OR NON-INFRINGEMENT. 
//
// See the Apache License, Version 2.0 for specific language governing 
// permissions and limitations under the License.
//
//
#include "quad_common.hlsli"

SamplerState _textureSampler : register(s0);
Texture2D _texture : register(t0); 

struct pixelShaderInput
{
    float4 point0 : SV_Position;
    float2 uv0 : TEXCOORD;
};

struct pixelShaderOutput
{
    float4 fragment : SV_Target;
};

pixelShaderOutput main(pixelShaderInput p)
{  
    const float blurSize = 1.0/256.f;

    pixelShaderOutput result;

    float4 sum = float4(0.0, 0.0, 0.0, 0.0);
 
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x - 4.0*blurSize, p.uv0.y)) * 0.05;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x - 3.0*blurSize, p.uv0.y)) * 0.09;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x - 2.0*blurSize, p.uv0.y)) * 0.12;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x - blurSize, p.uv0.y)) * 0.15;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x, p.uv0.y)) * 0.16;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x + blurSize, p.uv0.y)) * 0.15;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x + 2.0*blurSize, p.uv0.y)) * 0.12;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x + 3.0*blurSize, p.uv0.y)) * 0.09;
    sum += Texture1.Sample(TextureSampler, float2(p.uv0.x + 4.0*blurSize, p.uv0.y)) * 0.05;

    result.fragment = sum;
    result.fragment.a = 1;
    return result;
}
